package org.edu.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.edu.bean.City;
import org.edu.bean.County;
import org.edu.bean.Province;
import org.edu.dao.XZQHDao;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Service;

@Service
public class XZQHDaoImpl implements XZQHDao {

	@Resource
	private HibernateTemplate hibernateTemplate;
	
	@SuppressWarnings("unchecked")
	public List<Province> getAllProvinces() {
		
		return (List<Province>) hibernateTemplate.find("from Province");
	}

	@SuppressWarnings("unchecked")
	public List<Province> getProvinceById(int id) {
		return (List<Province>)hibernateTemplate.find("from Province p where p.proid = "+id);
	}

	@SuppressWarnings("unchecked")
	public List<City> getCityByPrId(int prid) {
		return (List<City>)hibernateTemplate.find("from City c where c.proid = "+prid);
	}

	@SuppressWarnings("unchecked")
	public List<County> getCountyByCiId(int ciId) {
		return (List<County>)hibernateTemplate.find("from County c where c.cityid = "+ciId);
	}

	@SuppressWarnings("unchecked")
	public List<City> getCityByCiId(int ciId) {
		
		return (List<City>)hibernateTemplate.find("from City c where c.cityid ="+ciId);
	}

	@SuppressWarnings("unchecked")
	public List<County> getCountyByCoId(int coId) {
		
		return (List<County>)hibernateTemplate.find("from County co where co.countyid = "+coId);
	}

}
